
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 05/06/2019 11:10:34
-- Generated from EDMX file: G:\workspace2\MvcDemo\Heima.OA.Model\DataModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [collectiondata];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_UserInfoOrderInfo]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OrderInfoSet] DROP CONSTRAINT [FK_UserInfoOrderInfo];
GO
IF OBJECT_ID(N'[dbo].[FK_UserInfoRoleInfo_UserInfo]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[UserInfoRoleInfo] DROP CONSTRAINT [FK_UserInfoRoleInfo_UserInfo];
GO
IF OBJECT_ID(N'[dbo].[FK_UserInfoRoleInfo_RoleInfo]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[UserInfoRoleInfo] DROP CONSTRAINT [FK_UserInfoRoleInfo_RoleInfo];
GO
IF OBJECT_ID(N'[dbo].[FK_RoleInfoActionInfo_RoleInfo]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[RoleInfoActionInfo] DROP CONSTRAINT [FK_RoleInfoActionInfo_RoleInfo];
GO
IF OBJECT_ID(N'[dbo].[FK_RoleInfoActionInfo_ActionInfo]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[RoleInfoActionInfo] DROP CONSTRAINT [FK_RoleInfoActionInfo_ActionInfo];
GO
IF OBJECT_ID(N'[dbo].[FK_UserInfoR_UserInfo_ActionInfo]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[R_UserInfo_ActionInfoSet] DROP CONSTRAINT [FK_UserInfoR_UserInfo_ActionInfo];
GO
IF OBJECT_ID(N'[dbo].[FK_ActionInfoR_UserInfo_ActionInfo]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[R_UserInfo_ActionInfoSet] DROP CONSTRAINT [FK_ActionInfoR_UserInfo_ActionInfo];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[UserInfoSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[UserInfoSet];
GO
IF OBJECT_ID(N'[dbo].[OrderInfoSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[OrderInfoSet];
GO
IF OBJECT_ID(N'[dbo].[RoleInfoSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RoleInfoSet];
GO
IF OBJECT_ID(N'[dbo].[ActionInfoSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ActionInfoSet];
GO
IF OBJECT_ID(N'[dbo].[R_UserInfo_ActionInfoSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[R_UserInfo_ActionInfoSet];
GO
IF OBJECT_ID(N'[dbo].[ZS_FamilyInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_FamilyInfo];
GO
IF OBJECT_ID(N'[dbo].[ZS_Member]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_Member];
GO
IF OBJECT_ID(N'[dbo].[ZS_BuildingInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_BuildingInfo];
GO
IF OBJECT_ID(N'[dbo].[ZS_HouseInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_HouseInfo];
GO
IF OBJECT_ID(N'[dbo].[ZS_JointApplicant]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_JointApplicant];
GO
IF OBJECT_ID(N'[dbo].[ZS_DeclareInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_DeclareInfo];
GO
IF OBJECT_ID(N'[dbo].[ZS_Attachment]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_Attachment];
GO
IF OBJECT_ID(N'[dbo].[ZS_Log]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_Log];
GO
IF OBJECT_ID(N'[dbo].[ZS_CheckFamilyInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_CheckFamilyInfo];
GO
IF OBJECT_ID(N'[dbo].[ZS_CheckMember]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_CheckMember];
GO
IF OBJECT_ID(N'[dbo].[ZS_CheckBuildingInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_CheckBuildingInfo];
GO
IF OBJECT_ID(N'[dbo].[ZS_CheckHouseInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_CheckHouseInfo];
GO
IF OBJECT_ID(N'[dbo].[ZS_CheckInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_CheckInfo];
GO
IF OBJECT_ID(N'[dbo].[ZS_CheckPrivatelyBusinessInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_CheckPrivatelyBusinessInfo];
GO
IF OBJECT_ID(N'[dbo].[ZS_CheckResettlementInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_CheckResettlementInfo];
GO
IF OBJECT_ID(N'[dbo].[Department]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Department];
GO
IF OBJECT_ID(N'[dbo].[ZS_CompensateInventory]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ZS_CompensateInventory];
GO
IF OBJECT_ID(N'[dbo].[UserInfoRoleInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[UserInfoRoleInfo];
GO
IF OBJECT_ID(N'[dbo].[RoleInfoActionInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RoleInfoActionInfo];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'UserInfoSet'
CREATE TABLE [dbo].[UserInfoSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [UName] nvarchar(32)  NULL,
    [Pwd] nvarchar(32)  NOT NULL,
    [ShowName] nvarchar(64)  NOT NULL,
    [DelFlag] smallint  NOT NULL,
    [Remark] nvarchar(256)  NULL,
    [ModifiedOn] datetime  NOT NULL,
    [SubTime] datetime  NOT NULL
);
GO

-- Creating table 'OrderInfoSet'
CREATE TABLE [dbo].[OrderInfoSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Content] nvarchar(64)  NULL,
    [UserInfoId] int  NOT NULL,
    [DelFlag] smallint  NOT NULL
);
GO

-- Creating table 'RoleInfoSet'
CREATE TABLE [dbo].[RoleInfoSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [RoleName] nvarchar(32)  NOT NULL,
    [DelFlag] smallint  NOT NULL,
    [Remark] nvarchar(256)  NULL,
    [ModifiedOn] datetime  NOT NULL,
    [SubTime] datetime  NOT NULL
);
GO

-- Creating table 'ActionInfoSet'
CREATE TABLE [dbo].[ActionInfoSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [DelFlag] smallint  NOT NULL,
    [Remark] nvarchar(256)  NULL,
    [ModifiedOn] datetime  NOT NULL,
    [SubTime] datetime  NOT NULL,
    [Url] nvarchar(512)  NOT NULL,
    [HttpMethod] nvarchar(32)  NULL,
    [ActionName] nvarchar(32)  NOT NULL,
    [IsMenu] smallint  NOT NULL,
    [MenuIcon] nvarchar(128)  NULL,
    [Sort] int  NULL
);
GO

-- Creating table 'R_UserInfo_ActionInfoSet'
CREATE TABLE [dbo].[R_UserInfo_ActionInfoSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [HasPermission] smallint  NOT NULL,
    [UserInfoId] int  NOT NULL,
    [ActionInfoId] int  NOT NULL,
    [DelFlag] smallint  NOT NULL
);
GO

-- Creating table 'ZS_FamilyInfo'
CREATE TABLE [dbo].[ZS_FamilyInfo] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [FamilyCode] nvarchar(32)  NULL,
    [SpouseMemberId] int  NULL,
    [SpouseMemberName] nvarchar(20)  NULL,
    [HuBie] nvarchar(20)  NULL,
    [PowerMemberName] nvarchar(20)  NULL,
    [PowerMemberId] int  NULL,
    [FamilyAddress] nvarchar(64)  NULL,
    [RegisterNumber] smallint  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL
);
GO

-- Creating table 'ZS_Member'
CREATE TABLE [dbo].[ZS_Member] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [FamilyId] int  NULL,
    [MemberName] nvarchar(20)  NULL,
    [WithPowerRelation] nvarchar(10)  NULL,
    [Sex] smallint  NULL,
    [MaritalStatus] nvarchar(10)  NULL,
    [Birthday] datetime  NULL,
    [IDNumber] nvarchar(32)  NULL,
    [IdentityType] nvarchar(20)  NULL,
    [RegisterInfo] nvarchar(48)  NULL,
    [Mobile] nvarchar(20)  NULL,
    [MoveIntoTime] datetime  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL
);
GO

-- Creating table 'ZS_BuildingInfo'
CREATE TABLE [dbo].[ZS_BuildingInfo] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [BuildingCode] nvarchar(20)  NULL,
    [BuildingName] nvarchar(32)  NULL,
    [Location] nvarchar(32)  NULL,
    [Floors] int  NULL,
    [BuildingStructure] nvarchar(32)  NULL,
    [HouseUse] nvarchar(20)  NULL,
    [ActualityUse] nvarchar(20)  NULL,
    [StructureArea] decimal(16,2)  NULL,
    [MappingArea] decimal(16,2)  NULL,
    [CompriseArea] decimal(16,2)  NULL,
    [JiDiArea] decimal(16,2)  NULL,
    [PropertyRight] nvarchar(20)  NULL,
    [BuiltTime] datetime  NULL,
    [IsObtainNoncommodityRightCertificate] smallint  NULL,
    [ObtainedCertificateName] nvarchar(32)  NULL,
    [CertificateCode] nvarchar(32)  NULL,
    [CetificateArea] decimal(16,2)  NULL,
    [NoObtainCertificateBuiltArea] decimal(16,2)  NULL,
    [Remark] nvarchar(256)  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL
);
GO

-- Creating table 'ZS_HouseInfo'
CREATE TABLE [dbo].[ZS_HouseInfo] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [BuildingId] int  NULL,
    [HouseName] nvarchar(20)  NULL,
    [HouseArea] decimal(16,2)  NULL,
    [DecorationSituation] nvarchar(20)  NULL,
    [ActualityUse] nvarchar(20)  NULL,
    [Remark] nvarchar(256)  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL,
    [DeclareId] int  NULL
);
GO

-- Creating table 'ZS_JointApplicant'
CREATE TABLE [dbo].[ZS_JointApplicant] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [MemberId] int  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL,
    [DeclareId] int  NULL
);
GO

-- Creating table 'ZS_DeclareInfo'
CREATE TABLE [dbo].[ZS_DeclareInfo] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [FamilyId] int  NULL,
    [MemberId] int  NULL,
    [MemberName] nvarchar(20)  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL,
    [CreateOperator] nvarchar(20)  NULL,
    [CreateOperatorId] int  NULL,
    [BuildingId] int  NULL,
    [IsTransferCheck] smallint  NULL
);
GO

-- Creating table 'ZS_Attachment'
CREATE TABLE [dbo].[ZS_Attachment] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [AttaType] nvarchar(20)  NULL,
    [UniqueName] nvarchar(40)  NULL,
    [FilePath] nvarchar(128)  NULL,
    [AttaName] nvarchar(32)  NULL,
    [BusinessType] smallint  NULL,
    [DataId] int  NULL,
    [Remark] nvarchar(256)  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL,
    [CreateOperator] nvarchar(20)  NULL,
    [CreateOperatorId] int  NULL
);
GO

-- Creating table 'ZS_Log'
CREATE TABLE [dbo].[ZS_Log] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [BusinessType] smallint  NULL,
    [DataId] int  NULL,
    [Content] nvarchar(256)  NULL,
    [CreateTime] datetime  NULL,
    [CreateOperator] nvarchar(20)  NULL,
    [CreateOperatorId] int  NULL
);
GO

-- Creating table 'ZS_CheckFamilyInfo'
CREATE TABLE [dbo].[ZS_CheckFamilyInfo] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [DeclareFamilyId] int  NULL,
    [FamilyCode] nvarchar(32)  NULL,
    [SpouseMemberId] int  NULL,
    [SpouseMemberName] nvarchar(20)  NULL,
    [HuBie] nvarchar(20)  NULL,
    [PowerMemberName] nvarchar(20)  NULL,
    [PowerMemberId] int  NULL,
    [FamilyAddress] nvarchar(64)  NULL,
    [RegisterNumber] smallint  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL
);
GO

-- Creating table 'ZS_CheckMember'
CREATE TABLE [dbo].[ZS_CheckMember] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [DeclareMemberId] int  NULL,
    [CheckFamilyId] int  NULL,
    [MemberName] nvarchar(20)  NULL,
    [WithPowerRelation] nvarchar(10)  NULL,
    [Sex] smallint  NULL,
    [MaritalStatus] nvarchar(10)  NULL,
    [Birthday] datetime  NULL,
    [IDNumber] nvarchar(32)  NULL,
    [IdentityType] nvarchar(20)  NULL,
    [RegisterInfo] nvarchar(48)  NULL,
    [Mobile] nvarchar(20)  NULL,
    [MoveIntoTime] datetime  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL,
    [DeclareFamilyId] int  NULL
);
GO

-- Creating table 'ZS_CheckBuildingInfo'
CREATE TABLE [dbo].[ZS_CheckBuildingInfo] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [BuildingCode] nvarchar(20)  NULL,
    [BuildingName] nvarchar(32)  NULL,
    [Location] nvarchar(32)  NULL,
    [Floors] int  NULL,
    [BuildingStructure] nvarchar(32)  NULL,
    [HouseUse] nvarchar(20)  NULL,
    [ActualityUse] nvarchar(20)  NULL,
    [StructureArea] decimal(16,2)  NULL,
    [MappingArea] decimal(16,2)  NULL,
    [CompriseArea] decimal(16,2)  NULL,
    [JiDiArea] decimal(16,2)  NULL,
    [PropertyRight] nvarchar(20)  NULL,
    [BuiltTime] datetime  NULL,
    [IsObtainNoncommodityRightCertificate] smallint  NULL,
    [ObtainedCertificateName] nvarchar(32)  NULL,
    [CertificateCode] nvarchar(32)  NULL,
    [CetificateArea] decimal(16,2)  NULL,
    [NoObtainCertificateBuiltArea] decimal(16,2)  NULL,
    [Remark] nvarchar(256)  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL,
    [DeclareBuildingId] int  NULL
);
GO

-- Creating table 'ZS_CheckHouseInfo'
CREATE TABLE [dbo].[ZS_CheckHouseInfo] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [DeclareHouseId] int  NULL,
    [CheckBuildingId] int  NULL,
    [HouseName] nvarchar(20)  NULL,
    [HouseArea] decimal(16,2)  NULL,
    [DecorationSituation] nvarchar(20)  NULL,
    [ActualityUse] nvarchar(20)  NULL,
    [Remark] nvarchar(120)  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL,
    [CheckId] int  NULL,
    [CerName] nvarchar(32)  NULL,
    [CerCode] nvarchar(32)  NULL,
    [RegisterRight] nvarchar(20)  NULL,
    [RegisterBuildingArea] decimal(16,2)  NULL,
    [ContractSigner] nvarchar(32)  NULL,
    [ContractRegisterBuildingArea] decimal(16,2)  NULL,
    [AttachmentId] int  NULL,
    [BuildingCode] nvarchar(20)  NULL,
    [ViolationOriginCode] nvarchar(32)  NULL,
    [IsBuiltBeforeDate] smallint  NULL,
    [BuiltAreaBeforeDate] decimal(16,2)  NULL,
    [BuiltAreaAfterDate] decimal(16,2)  NULL,
    [ViolationBuiltArea] decimal(16,2)  NULL,
    [DeclareBuildingId] int  NULL
);
GO

-- Creating table 'ZS_CheckInfo'
CREATE TABLE [dbo].[ZS_CheckInfo] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [JingbanPerson] nvarchar(20)  NULL,
    [CheckPerson] nvarchar(20)  NULL,
    [CheckDate] datetime  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL,
    [CreateOperator] nvarchar(20)  NULL,
    [CreateOperatorId] int  NULL,
    [FamilyId] int  NULL,
    [BuildingId] int  NULL
);
GO

-- Creating table 'ZS_CheckPrivatelyBusinessInfo'
CREATE TABLE [dbo].[ZS_CheckPrivatelyBusinessInfo] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [BuildingCode] nvarchar(20)  NULL,
    [StoreName] nvarchar(50)  NULL,
    [CerNameCode] nvarchar(64)  NULL,
    [OperatorName] nvarchar(20)  NULL,
    [OperatorProveFileName] nvarchar(64)  NULL,
    [ActualMonths] int  NULL,
    [PrivateArea] decimal(16,2)  NULL,
    [OnFloor] nvarchar(20)  NULL,
    [BuildingId] int  NULL,
    [CheckId] int  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL
);
GO

-- Creating table 'ZS_CheckResettlementInfo'
CREATE TABLE [dbo].[ZS_CheckResettlementInfo] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [MemberNames] nvarchar(64)  NULL,
    [ItemName] nvarchar(32)  NULL,
    [RightCerName] nvarchar(64)  NULL,
    [CerCode] nvarchar(32)  NULL,
    [RegisterBuildingArea] decimal(16,2)  NULL,
    [AllocateArea] decimal(16,2)  NULL,
    [ReturnHouseCode] nvarchar(32)  NULL,
    [ReturnHouseArea] decimal(16,2)  NULL,
    [OtherItemName] nvarchar(32)  NULL,
    [OtherAllocateArea] decimal(16,2)  NOT NULL,
    [MoneyCompensateArea] decimal(16,2)  NULL,
    [SumArea] decimal(16,2)  NULL,
    [FamilyId] int  NULL,
    [CheckId] int  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL
);
GO

-- Creating table 'Department'
CREATE TABLE [dbo].[Department] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [DeptName] nvarchar(32)  NULL,
    [DeptCode] nvarchar(32)  NULL,
    [ParentId] int  NULL,
    [IsLeaf] smallint  NULL,
    [IsCheck] smallint  NULL,
    [Remark] nvarchar(128)  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL,
    [ModifiedOn] datetime  NULL,
    [Sort] int  NULL
);
GO

-- Creating table 'ZS_CompensateInventory'
CREATE TABLE [dbo].[ZS_CompensateInventory] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [CheckIds] nvarchar(20)  NULL,
    [MemberIds] nvarchar(32)  NULL,
    [MemberNames] nvarchar(50)  NULL,
    [House] nvarchar(50)  NULL,
    [Land] nvarchar(64)  NULL,
    [TempBuilding] nvarchar(64)  NULL,
    [IndoorDecorate] nvarchar(32)  NULL,
    [YoungCrops] nvarchar(64)  NULL,
    [RemovalFee] nvarchar(32)  NULL,
    [TempPlaceFee] nvarchar(32)  NULL,
    [PrivateUseFee] nvarchar(32)  NULL,
    [StopProductionFee] nvarchar(32)  NULL,
    [OtherAllowance] nvarchar(64)  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL,
    [CreateOperator] nvarchar(20)  NULL
);
GO

-- Creating table 'UserDepartment'
CREATE TABLE [dbo].[UserDepartment] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [UserId] int  NULL,
    [DeptId] int  NULL
);
GO

-- Creating table 'ZS_Audit'
CREATE TABLE [dbo].[ZS_Audit] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [DataId] int  NULL,
    [BusinessType] int  NULL,
    [RecordState] smallint  NULL,
    [DelFlag] smallint  NULL,
    [CreateTime] datetime  NULL,
    [AuditOnePerson] nvarchar(20)  NULL,
    [AuditOneTime] datetime  NULL,
    [AuditOneState] smallint  NULL,
    [AuditOneRemark] nvarchar(64)  NULL,
    [AuditTwoPerson] nvarchar(20)  NULL,
    [AuditTwoTime] datetime  NULL,
    [AuditTwoState] smallint  NULL,
    [AuditTwoRemark] nvarchar(64)  NULL,
    [AuditThreePerson] nvarchar(20)  NULL,
    [AuditThreeTime] datetime  NULL,
    [AuditThreeState] smallint  NULL,
    [AuditThreeRemark] nvarchar(64)  NULL
);
GO

-- Creating table 'UserInfoRoleInfo'
CREATE TABLE [dbo].[UserInfoRoleInfo] (
    [UserInfo_Id] int  NOT NULL,
    [RoleInfo_Id] int  NOT NULL
);
GO

-- Creating table 'RoleInfoActionInfo'
CREATE TABLE [dbo].[RoleInfoActionInfo] (
    [RoleInfo_Id] int  NOT NULL,
    [ActionInfo_Id] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'UserInfoSet'
ALTER TABLE [dbo].[UserInfoSet]
ADD CONSTRAINT [PK_UserInfoSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'OrderInfoSet'
ALTER TABLE [dbo].[OrderInfoSet]
ADD CONSTRAINT [PK_OrderInfoSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'RoleInfoSet'
ALTER TABLE [dbo].[RoleInfoSet]
ADD CONSTRAINT [PK_RoleInfoSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ActionInfoSet'
ALTER TABLE [dbo].[ActionInfoSet]
ADD CONSTRAINT [PK_ActionInfoSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'R_UserInfo_ActionInfoSet'
ALTER TABLE [dbo].[R_UserInfo_ActionInfoSet]
ADD CONSTRAINT [PK_R_UserInfo_ActionInfoSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_FamilyInfo'
ALTER TABLE [dbo].[ZS_FamilyInfo]
ADD CONSTRAINT [PK_ZS_FamilyInfo]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_Member'
ALTER TABLE [dbo].[ZS_Member]
ADD CONSTRAINT [PK_ZS_Member]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_BuildingInfo'
ALTER TABLE [dbo].[ZS_BuildingInfo]
ADD CONSTRAINT [PK_ZS_BuildingInfo]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_HouseInfo'
ALTER TABLE [dbo].[ZS_HouseInfo]
ADD CONSTRAINT [PK_ZS_HouseInfo]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_JointApplicant'
ALTER TABLE [dbo].[ZS_JointApplicant]
ADD CONSTRAINT [PK_ZS_JointApplicant]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_DeclareInfo'
ALTER TABLE [dbo].[ZS_DeclareInfo]
ADD CONSTRAINT [PK_ZS_DeclareInfo]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_Attachment'
ALTER TABLE [dbo].[ZS_Attachment]
ADD CONSTRAINT [PK_ZS_Attachment]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_Log'
ALTER TABLE [dbo].[ZS_Log]
ADD CONSTRAINT [PK_ZS_Log]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_CheckFamilyInfo'
ALTER TABLE [dbo].[ZS_CheckFamilyInfo]
ADD CONSTRAINT [PK_ZS_CheckFamilyInfo]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_CheckMember'
ALTER TABLE [dbo].[ZS_CheckMember]
ADD CONSTRAINT [PK_ZS_CheckMember]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_CheckBuildingInfo'
ALTER TABLE [dbo].[ZS_CheckBuildingInfo]
ADD CONSTRAINT [PK_ZS_CheckBuildingInfo]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_CheckHouseInfo'
ALTER TABLE [dbo].[ZS_CheckHouseInfo]
ADD CONSTRAINT [PK_ZS_CheckHouseInfo]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_CheckInfo'
ALTER TABLE [dbo].[ZS_CheckInfo]
ADD CONSTRAINT [PK_ZS_CheckInfo]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_CheckPrivatelyBusinessInfo'
ALTER TABLE [dbo].[ZS_CheckPrivatelyBusinessInfo]
ADD CONSTRAINT [PK_ZS_CheckPrivatelyBusinessInfo]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_CheckResettlementInfo'
ALTER TABLE [dbo].[ZS_CheckResettlementInfo]
ADD CONSTRAINT [PK_ZS_CheckResettlementInfo]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Department'
ALTER TABLE [dbo].[Department]
ADD CONSTRAINT [PK_Department]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_CompensateInventory'
ALTER TABLE [dbo].[ZS_CompensateInventory]
ADD CONSTRAINT [PK_ZS_CompensateInventory]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'UserDepartment'
ALTER TABLE [dbo].[UserDepartment]
ADD CONSTRAINT [PK_UserDepartment]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZS_Audit'
ALTER TABLE [dbo].[ZS_Audit]
ADD CONSTRAINT [PK_ZS_Audit]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [UserInfo_Id], [RoleInfo_Id] in table 'UserInfoRoleInfo'
ALTER TABLE [dbo].[UserInfoRoleInfo]
ADD CONSTRAINT [PK_UserInfoRoleInfo]
    PRIMARY KEY CLUSTERED ([UserInfo_Id], [RoleInfo_Id] ASC);
GO

-- Creating primary key on [RoleInfo_Id], [ActionInfo_Id] in table 'RoleInfoActionInfo'
ALTER TABLE [dbo].[RoleInfoActionInfo]
ADD CONSTRAINT [PK_RoleInfoActionInfo]
    PRIMARY KEY CLUSTERED ([RoleInfo_Id], [ActionInfo_Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [UserInfoId] in table 'OrderInfoSet'
ALTER TABLE [dbo].[OrderInfoSet]
ADD CONSTRAINT [FK_UserInfoOrderInfo]
    FOREIGN KEY ([UserInfoId])
    REFERENCES [dbo].[UserInfoSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_UserInfoOrderInfo'
CREATE INDEX [IX_FK_UserInfoOrderInfo]
ON [dbo].[OrderInfoSet]
    ([UserInfoId]);
GO

-- Creating foreign key on [UserInfo_Id] in table 'UserInfoRoleInfo'
ALTER TABLE [dbo].[UserInfoRoleInfo]
ADD CONSTRAINT [FK_UserInfoRoleInfo_UserInfo]
    FOREIGN KEY ([UserInfo_Id])
    REFERENCES [dbo].[UserInfoSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [RoleInfo_Id] in table 'UserInfoRoleInfo'
ALTER TABLE [dbo].[UserInfoRoleInfo]
ADD CONSTRAINT [FK_UserInfoRoleInfo_RoleInfo]
    FOREIGN KEY ([RoleInfo_Id])
    REFERENCES [dbo].[RoleInfoSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_UserInfoRoleInfo_RoleInfo'
CREATE INDEX [IX_FK_UserInfoRoleInfo_RoleInfo]
ON [dbo].[UserInfoRoleInfo]
    ([RoleInfo_Id]);
GO

-- Creating foreign key on [RoleInfo_Id] in table 'RoleInfoActionInfo'
ALTER TABLE [dbo].[RoleInfoActionInfo]
ADD CONSTRAINT [FK_RoleInfoActionInfo_RoleInfo]
    FOREIGN KEY ([RoleInfo_Id])
    REFERENCES [dbo].[RoleInfoSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ActionInfo_Id] in table 'RoleInfoActionInfo'
ALTER TABLE [dbo].[RoleInfoActionInfo]
ADD CONSTRAINT [FK_RoleInfoActionInfo_ActionInfo]
    FOREIGN KEY ([ActionInfo_Id])
    REFERENCES [dbo].[ActionInfoSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_RoleInfoActionInfo_ActionInfo'
CREATE INDEX [IX_FK_RoleInfoActionInfo_ActionInfo]
ON [dbo].[RoleInfoActionInfo]
    ([ActionInfo_Id]);
GO

-- Creating foreign key on [UserInfoId] in table 'R_UserInfo_ActionInfoSet'
ALTER TABLE [dbo].[R_UserInfo_ActionInfoSet]
ADD CONSTRAINT [FK_UserInfoR_UserInfo_ActionInfo]
    FOREIGN KEY ([UserInfoId])
    REFERENCES [dbo].[UserInfoSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_UserInfoR_UserInfo_ActionInfo'
CREATE INDEX [IX_FK_UserInfoR_UserInfo_ActionInfo]
ON [dbo].[R_UserInfo_ActionInfoSet]
    ([UserInfoId]);
GO

-- Creating foreign key on [ActionInfoId] in table 'R_UserInfo_ActionInfoSet'
ALTER TABLE [dbo].[R_UserInfo_ActionInfoSet]
ADD CONSTRAINT [FK_ActionInfoR_UserInfo_ActionInfo]
    FOREIGN KEY ([ActionInfoId])
    REFERENCES [dbo].[ActionInfoSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_ActionInfoR_UserInfo_ActionInfo'
CREATE INDEX [IX_FK_ActionInfoR_UserInfo_ActionInfo]
ON [dbo].[R_UserInfo_ActionInfoSet]
    ([ActionInfoId]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------